<?php

class HTech_Controller_Action_Helper_Cache extends Zend_Controller_Action_Helper_Abstract
{
    private $_tags;
    private $_cache;
    
    public function __construct() 
    {
        $identity = Zend_Auth::getInstance()->getIdentity();
        
        $frontendOptions = array(
            'lifetime' => 7200, 
            'automatic_serialization' => true, 
            'cache_id_prefix' => sprintf('%s_%s_%s_',$identity->emmsClient,$identity->emmsDb,$identity->UserId)
            );
        $backendOptions = array('cache_dir' => '../tmp/');
        
        $this->_tags = array($identity->emmsClient, $identity->emmsDb, 'user', $identity->UserId);
        $this->_cache = Zend_Cache::factory('Core','File', $frontendOptions, $backendOptions);
    }
    
    public function save($content,$page)
    {
        $this->_cache->save($content, $page, $this->_tags);
    }
    
    public function load($page)
    {
        return $this->_cache->load($page);
    }
}
